package com.erdos.common.web;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;

/**
 * ---------------------------------------------------------------------------------
 Confidential and Proprietary                                                                
 Copyright 2008 By                                                                                     
 SGAI & Hewlett-Packard Development Company, L.P. 	              
 All Rights Reserved                                                                                  

 Project Name : SGAI  MES                                                                                                                                       
 Class Name   : Log4jInitServlet.java    
 Package      : com.hp.common.web                                                                   
 @version     $Id: Log4jInitServlet.java 9124 2012-03-08 03:00:56Z hubin $                                                          
 @author yehuo
 @since  Jun 3, 2009 
 */
public class Log4jInitServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        // URL url = null;
        // String resource = this.getServletConfig().getInitParameter(
        // "log4j-init-file");
        // ClassLoader loader = Class.class.getClassLoader();
        // if (loader != null)
        // url = loader.getResource(resource);
        // if (url == null)
        // url = ClassLoader.getSystemResource(resource);
        // if (url != null)
        // DOMConfigurator.configure(url);

        // Properties prop = new Properties();
        // InputStream in = null;
        // try {
        // in = getResourceAsStream("log4j.properties");
        // prop.load(in);
        //
        // PropertyConfigurator.configure(prop);
        // } catch (IOException e) {
        // System.out.println(e);
        // } finally {
        // if (null != in)
        // try {
        // in.close();
        // } catch (Exception ex) {
        // }
        // }
        //        
        // prop = new Properties();
        // in = null;
        // try {
        // in = getResourceAsStream("log4j.properties");
        // prop.load(in);
        //
        // PropertyConfigurator.configure(prop);
        // } catch (IOException e) {
        // System.out.println(e);
        // } finally {
        // if (null != in)
        // try {
        // in.close();
        // } catch (Exception ex) {
        // }
        // }
//        Log logger = LogFactory.getLog(this.getClass());
//        logger.info("************common-loggin is comming!");
//        System.out.println("**********Log4j configuration was loaded!");
        
        Logger logger = Logger.getLogger(Class.class);  
//        logger.info(message)
    }

    // private InputStream getResourceAsStream(String resource) throws
    // IOException {
    // InputStream in = null;
    // ClassLoader loader = Log4jInitServlet.class.getClassLoader();
    // if (loader != null)
    // in = loader.getResourceAsStream(resource);
    // if (in == null)
    // in = ClassLoader.getSystemResourceAsStream(resource);
    // if (in == null)
    // throw new IOException("Could not find resource " + resource);
    // return in;
    // }
    //    

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
    }

}
